﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace IoTClient.WinformExt.FormS
{
    public partial class frm_VarableDetailes : Form
    {
        public frm_VarableDetailes()
        {
            InitializeComponent();
        }

        private List<Variable> varlist;

        public frm_VarableDetailes(List<Variable> variables)
        {
            InitializeComponent();
            this.dataGridView_VarableDetailes.DataSource = variables;
            varlist = variables;
        }

        private void DeleteVarable(object sender, EventArgs e)
        {
            var rows = dataGridView_VarableDetailes.SelectedRows;
            foreach (DataGridViewRow row in rows)
            {
                varlist.Remove((Variable)(row.DataBoundItem));
            }
            this.dataGridView_VarableDetailes.DataSource = null;
            this.dataGridView_VarableDetailes.DataSource = varlist;
        }

        private void AddVarable(object sender, EventArgs e)
        {
            varlist.Add(new Variable());
            this.dataGridView_VarableDetailes.DataSource = null;
            this.dataGridView_VarableDetailes.DataSource = varlist;
        }
    }
}